/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author christianhansen
 */
public class SyncHeapRun extends javax.swing.JFrame {

    /**
     * Creates new form SyncHeapRun
     */
    public SyncHeapRun() {
        initComponents();
        
        int min = 30;  int max = 90;  int tot = max - min + 1;
        String [] values = new String[tot];
        for(int i = 0; i < tot ; i++) {
            values[i] = Integer.toString(min + i);
        }
        maxItemsComboBox.setModel(new javax.swing.DefaultComboBoxModel(values));

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        runButton = new javax.swing.JButton();
        heapTitleLabel = new javax.swing.JLabel();
        heapLabel = new javax.swing.JLabel();
        stopButton = new javax.swing.JButton();
        javax.swing.SpinnerModel prodModel = new javax.swing.SpinnerNumberModel( 1,  //initial value
            1,  //min
            10,  //max
            1); //step
        producerSpinner = new javax.swing.JSpinner(prodModel);
        javax.swing.SpinnerModel consModel = new javax.swing.SpinnerNumberModel( 1,  //initial value
            1,  //min
            10,  //max
            1); //step
        consumerSpinner = new javax.swing.JSpinner(consModel);
        integerRadioButton = new javax.swing.JRadioButton();
        characterRadioButton = new javax.swing.JRadioButton();
        treeRadioButton = new javax.swing.JRadioButton();
        arrayRadioButton = new javax.swing.JRadioButton();
        maxItemsComboBox = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        javax.swing.SpinnerModel prodTimeModel = new javax.swing.SpinnerNumberModel( 0.5,  //initial value
            0.5,  //min
            3.0,  //max
            0.5); //step
        prodTimeSpinner = new javax.swing.JSpinner(prodTimeModel);
        prodTimeRandomRadioButton = new javax.swing.JRadioButton();
        prodTimeLabel = new javax.swing.JLabel();
        consTimeRandomRadioButton = new javax.swing.JRadioButton();
        consTimeLabel = new javax.swing.JLabel();
        javax.swing.SpinnerModel consTimeModel = new javax.swing.SpinnerNumberModel( 0.5,  //initial value
            0.5,  //min
            3.0,  //max
            0.5); //step
        consTimeSpinner = new javax.swing.JSpinner(consTimeModel);
        consumedLabel = new javax.swing.JLabel();
        prodLabel = new javax.swing.JLabel();
        stdRadioButton = new javax.swing.JRadioButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Synchronized Heap Sort");

        jLabel1.setFont(new java.awt.Font("Lucida Grande", 3, 13)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Synchronized Heap Sort:");

        jLabel2.setText("How many Producers do you want?");

        jLabel3.setText("How many Consumers do you want?");

        runButton.setBackground(new java.awt.Color(0, 204, 51));
        runButton.setText("Run");
        runButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                runButtonActionPerformed(evt);
            }
        });

        heapTitleLabel.setText("HEAP:");

        heapLabel.setBackground(new java.awt.Color(255, 255, 0));
        heapLabel.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        heapLabel.setForeground(new java.awt.Color(51, 51, 51));
        heapLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        heapLabel.setText(null);
        heapLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        heapLabel.setAutoscrolls(true);
        heapLabel.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(204, 51, 0)));

        stopButton.setBackground(new java.awt.Color(255, 51, 51));
        stopButton.setText("Stop");
        stopButton.setEnabled(false);
        stopButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopButtonActionPerformed(evt);
            }
        });

        buttonGroup1.add(integerRadioButton);
        integerRadioButton.setSelected(true);
        integerRadioButton.setText("Fill with Integers");
        integerRadioButton.setAlignmentY(0.0F);
        integerRadioButton.setBorder(null);
        integerRadioButton.setFocusable(false);

        buttonGroup1.add(characterRadioButton);
        characterRadioButton.setText("Fill with Characters");
        characterRadioButton.setAlignmentY(0.0F);
        characterRadioButton.setBorder(null);
        characterRadioButton.setFocusable(false);

        buttonGroup2.add(treeRadioButton);
        treeRadioButton.setText("Dynamic Tree Represents the Heap");
        treeRadioButton.setAlignmentY(0.0F);
        treeRadioButton.setBorder(null);

        buttonGroup2.add(arrayRadioButton);
        arrayRadioButton.setSelected(true);
        arrayRadioButton.setText("Dynamic Array Represents the Heap");
        arrayRadioButton.setAlignmentY(0.0F);
        arrayRadioButton.setBorder(null);

        maxItemsComboBox.setEditable(true);
        maxItemsComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel4.setText("Max number items in Heap:");

        prodTimeSpinner.setEnabled(false);

        prodTimeRandomRadioButton.setSelected(true);
        prodTimeRandomRadioButton.setText("Random Item Production Time");
        prodTimeRandomRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                prodTimeRandomRadioButtonActionPerformed(evt);
            }
        });

        prodTimeLabel.setText("Number seconds to produce an item.");
        prodTimeLabel.setEnabled(false);

        consTimeRandomRadioButton.setSelected(true);
        consTimeRandomRadioButton.setText("Random Item Consumption Time");
        consTimeRandomRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                consTimeRandomRadioButtonActionPerformed(evt);
            }
        });

        consTimeLabel.setText("Number seconds to consume an item.");
        consTimeLabel.setEnabled(false);

        consTimeSpinner.setEnabled(false);

        consumedLabel.setText("Nothing consumed yet...");

        prodLabel.setText("Nothing produced yet...");

        stdRadioButton.setText("Also print to std-out");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(heapLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 1201, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(366, 366, 366))
            .add(layout.createSequentialGroup()
                .add(24, 24, 24)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(integerRadioButton)
                            .add(characterRadioButton))
                        .add(173, 173, 173)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                .add(layout.createSequentialGroup()
                                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(consTimeRandomRadioButton)
                                        .add(layout.createSequentialGroup()
                                            .add(consTimeSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                            .add(consTimeLabel)))
                                    .add(298, 298, 298)
                                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                        .add(runButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 57, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(stopButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 57, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                                    .add(prodTimeSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(prodTimeLabel)
                                    .add(124, 124, 124)
                                    .add(stdRadioButton)))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                                .add(prodTimeRandomRadioButton)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .add(jLabel4)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(maxItemsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 58, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                    .add(treeRadioButton)
                    .add(arrayRadioButton)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel2)
                            .add(jLabel3))
                        .add(18, 18, 18)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(producerSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(consumerSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(heapTitleLabel))
                .add(0, 0, Short.MAX_VALUE))
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(453, 453, 453)
                        .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 164, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(layout.createSequentialGroup()
                        .add(373, 373, 373)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(prodLabel)
                            .add(consumedLabel))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(layout.createSequentialGroup()
                        .add(jLabel1)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(producerSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel2)))
                    .add(prodLabel))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, consumerSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel3)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, consumedLabel))
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(27, 27, 27)
                        .add(integerRadioButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(characterRadioButton))
                    .add(layout.createSequentialGroup()
                        .add(28, 28, 28)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(prodTimeRandomRadioButton)
                            .add(jLabel4)
                            .add(maxItemsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(prodTimeLabel)
                                .add(stdRadioButton))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, prodTimeSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                .add(18, 18, 18)
                                .add(runButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 43, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(stopButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 44, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(layout.createSequentialGroup()
                                .add(32, 32, 32)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                    .add(layout.createSequentialGroup()
                                        .add(consTimeRandomRadioButton)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(org.jdesktop.layout.GroupLayout.TRAILING, consTimeLabel)
                                            .add(org.jdesktop.layout.GroupLayout.TRAILING, consTimeSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                    .add(layout.createSequentialGroup()
                                        .add(arrayRadioButton)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(treeRadioButton)))))))
                .add(14, 14, 14)
                .add(heapTitleLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(heapLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 164, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(86, 86, 86))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-1218)/2, (screenSize.height-525)/2, 1218, 525);
    }// </editor-fold>//GEN-END:initComponents

    private void syncHeapTest() {
        boolean useCharacters = characterRadioButton.isSelected();
        boolean useTree = treeRadioButton.isSelected();
        boolean useRandomProdTime = prodTimeRandomRadioButton.isSelected();
        boolean useRandomConsTime = consTimeRandomRadioButton.isSelected();
        double prodTime = 0;
        if (prodTimeSpinner.isEnabled()) prodTime = (Double)(prodTimeSpinner.getValue());
        double consTime = 0;
        if (consTimeSpinner.isEnabled()) consTime = (Double)(consTimeSpinner.getValue());
        int maxN = Integer.parseInt((String)maxItemsComboBox.getSelectedItem());
        m_nbrProducers = (Integer)(producerSpinner.getValue());
        m_nbrConsumers = (Integer)(consumerSpinner.getValue());
        boolean printToStd = stdRadioButton.isSelected();
	

	int N_CPUS = Runtime.getRuntime().availableProcessors();
	if (printToStd) System.out.println(N_CPUS + " processors/cores detected.");

	// The shared heap   
        SyncHeap heap;
        if (useCharacters) {
            heap = new SyncHeap<Character>(maxN, new Character('*'), 
                    heapLabel, heapTitleLabel, useTree, printToStd);
        } else {
            heap = new SyncHeap<Integer>(maxN, new Integer(-999), 
                    heapLabel, heapTitleLabel, useTree, printToStd);  
        }
	// Create and start producers
	m_producerThreads = new Thread[m_nbrProducers];
	for (int i = 0; i < m_nbrProducers; i++) {
            Producer p;
            if (useCharacters) {                  //they ALL get the same heap
                p = new CharProducer<Character>(i, heap, prodLabel, prodTime, 
                        useRandomProdTime, printToStd);  
            } else {
                p = new Producer<Integer>(i, heap, prodLabel, prodTime, 
                        useRandomProdTime, printToStd);  
            }
            m_producerThreads[i] = new Thread(p);
	    m_producerThreads[i].start();
	}
	
	// Create and start consumers
	m_consumerThreads = new Thread[m_nbrConsumers];
	for (int i = 0; i < m_nbrConsumers; i++) {
            Consumer c;
            if (useCharacters) {              //they ALL get the same heap
                c = new Consumer<Character>(i, heap, consumedLabel, consTime, 
                        useRandomConsTime, printToStd);
            } else {
                c = new Consumer<Integer>(i, heap, consumedLabel, consTime, 
                        useRandomConsTime, printToStd);  
            }
	    m_consumerThreads[i] = new Thread(c);
	    m_consumerThreads[i].start();
	}
        
        
//	
//        ReadStd reader = new ReadStd();
//	reader.readStdLine("Push any key to stop..");
//	
//
//	for (int i = 0; i < nbrConsumers; i++) {
//	    consumerThreads[i].interrupt();
//	}
//	for (int i = 0; i < nbrProducers; i++) {
//	    producerThreads[i].interrupt();
//	}
//
//	for (int i = 0; i < nbrProducers; i++) {
//	    try { producerThreads[i].join(); } catch(InterruptedException e) {e.printStackTrace();} 
//	}
//	for (int i = 0; i < nbrConsumers; i++) {
//	    try { consumerThreads[i].join(); } catch(InterruptedException e) {e.printStackTrace();}
//	}
    }
    
    private void runButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runButtonActionPerformed
        stopButton.setEnabled(true);
        runButton.setEnabled(false);
        syncHeapTest();
    }//GEN-LAST:event_runButtonActionPerformed

    private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopButtonActionPerformed
     	for (int i = 0; i < m_nbrConsumers; i++) {
	    m_consumerThreads[i].interrupt();
    	}
	for (int i = 0; i < m_nbrProducers; i++) {
	    m_producerThreads[i].interrupt();
	}
	for (int i = 0; i < m_nbrProducers; i++) {
	    try { m_producerThreads[i].join(); } catch(InterruptedException e) {e.printStackTrace();} 
	}
	for (int i = 0; i < m_nbrConsumers; i++) {
	    try { m_consumerThreads[i].join(); } catch(InterruptedException e) {e.printStackTrace();}
	}
        stopButton.setEnabled(false);
        runButton.setEnabled(true);
    }//GEN-LAST:event_stopButtonActionPerformed

    private void prodTimeRandomRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prodTimeRandomRadioButtonActionPerformed
        if (prodTimeRandomRadioButton.isSelected()) {
            prodTimeSpinner.setEnabled(false);
            prodTimeLabel.setEnabled(false);
        } else {
            prodTimeSpinner.setEnabled(true);
            prodTimeLabel.setEnabled(true);
        }
    }//GEN-LAST:event_prodTimeRandomRadioButtonActionPerformed

    private void consTimeRandomRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_consTimeRandomRadioButtonActionPerformed
        if (consTimeRandomRadioButton.isSelected()) {
            consTimeSpinner.setEnabled(false);
            consTimeLabel.setEnabled(false);
        } else {
            consTimeSpinner.setEnabled(true);
            consTimeLabel.setEnabled(true);
        }
    }//GEN-LAST:event_consTimeRandomRadioButtonActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(SyncHeapRun.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(SyncHeapRun.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(SyncHeapRun.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(SyncHeapRun.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new SyncHeapRun().setVisible(true);
            }
        });
    }
    
    private Thread[] m_producerThreads;
    private Thread[] m_consumerThreads;
    private int m_nbrProducers;
    private int m_nbrConsumers;
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton arrayRadioButton;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JRadioButton characterRadioButton;
    private javax.swing.JLabel consTimeLabel;
    private javax.swing.JRadioButton consTimeRandomRadioButton;
    private javax.swing.JSpinner consTimeSpinner;
    private javax.swing.JLabel consumedLabel;
    private javax.swing.JSpinner consumerSpinner;
    private javax.swing.JLabel heapLabel;
    private javax.swing.JLabel heapTitleLabel;
    private javax.swing.JRadioButton integerRadioButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JComboBox maxItemsComboBox;
    private javax.swing.JLabel prodLabel;
    private javax.swing.JLabel prodTimeLabel;
    private javax.swing.JRadioButton prodTimeRandomRadioButton;
    private javax.swing.JSpinner prodTimeSpinner;
    private javax.swing.JSpinner producerSpinner;
    private javax.swing.JButton runButton;
    private javax.swing.JRadioButton stdRadioButton;
    private javax.swing.JButton stopButton;
    private javax.swing.JRadioButton treeRadioButton;
    // End of variables declaration//GEN-END:variables
}
